package com.gxgy.app.controller;

import com.gxgy.app.doman.po.Goods;
import com.gxgy.app.service.GoodsService;
import com.gxgy.common.core.domain.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/app/goods")
public class GoodsController {
    @Resource
    private GoodsService goodsService;


    @GetMapping("/list/classify/{id}")
    public R<List<Goods>> getGoodsByClassify(@PathVariable Long id){
        List<Goods> list = goodsService.goodsByClassify(id);
        return R.ok(list);
    }

    @GetMapping("/{id}")
    public R<Goods> getGoodsById(@PathVariable Long id){
        Goods byId = goodsService.getById(id);
        return R.ok(byId);
    }

    @GetMapping("/list")
    public R<List<Goods>> getGoodsList() {
        List<Goods> list = goodsService.list();
        return R.ok(list);
    }
}


